package com.kayo.specimen.config;

import com.kayo.specimen.converter.OrderByBuilderConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ConversionServiceFactoryBean;
import org.springframework.core.convert.converter.Converter;

import java.util.HashSet;
import java.util.Set;

@Configuration
public class ConverterConfig {

    @Bean
    public OrderByBuilderConverter orderByBuilderConverter() {
        return new OrderByBuilderConverter();
    }

    @Bean
    public ConversionServiceFactoryBean conversionServiceFactoryBean() {
        ConversionServiceFactoryBean conversionServiceFactoryBean = new ConversionServiceFactoryBean();
        Set<Converter> set = new HashSet<>();
        set.add(orderByBuilderConverter());
        conversionServiceFactoryBean.setConverters(set);
        return conversionServiceFactoryBean;
    }
}
